#light
open FSharp
let doc = Xml.readFromFile @"C:\Users\robert\Documents\Visual Studio 2008\Projects\FsXml\FsXml\doc.xml"
Xml.writeTreeToString doc // @"C:\Users\robert\Documents\Visual Studio 2008\Projects\FsXml\FsXml\doc2.xml" doc

let xaml = Xml.readFromFile @"C:\Users\robert\Documents\Visual Studio 2008\Projects\FsXml\FsXml\animatedsnowboarder.xaml"
Xml.writeToFile @"C:\Users\robert\Documents\Visual Studio 2008\Projects\FsXml\FsXml\animatedsnowboarder2.xaml" xaml

let address x = Xml.textElement "address" [] x

Xml.writeTreeToFile  @"C:\Users\robert\Documents\Visual Studio 2008\Projects\FsXml\FsXml\snowboard.fs"  xaml // (address "toto")

Xml.textElement "address" [] "toto"

do read_line() |> ignore

Xml.element "address" [] (  Xml.text "toto" )

let xaml2 =
    Xml.elementList [  Xml.comment " Saved from Aurora XAML Designer for WinFX - Mobiform Software Ltd. - Thursday, August 10, 2006 3:50:33 PM " 
    ;   Xml.element "Canvas" [ "Name", "Canvas1"; "Width", "560"; "Height", "326"; "ClipToBounds", "True"; "xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"; "xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation";] (    Xml.elementList [      Xml.element "Canvas.Background" [] (        Xml.element "LinearGradientBrush" [ "Opacity", "1";] (          Xml.element "LinearGradientBrush.GradientStops" [] (            Xml.elementList [              Xml.emptyElement "GradientStop" [ "Color", "White"; "Offset", "0";]
    ;               Xml.emptyElement "GradientStop" [ "Color", "#FF1620FF"; "Offset", "1";]
    ;             ]           )
            )
          )
    ;       Xml.element "Canvas.Resources" [] (        Xml.element "Storyboard" [ "x:Key", "Storyboard_0"; "BeginTime", "00:00:00"; "Duration", "00:00:07"; "SpeedRatio", "1";] (          Xml.element "Storyboard.Children" [] (            Xml.elementList [              Xml.element "DoubleAnimationUsingKeyFrames" [ "Storyboard.TargetName", "Viewbox2"; "Storyboard.TargetProperty", "(Canvas.Left)";] (                Xml.elementList [                  Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:00"; "Value", "-193";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:00.7110000"; "Value", "-51.5408163265306";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:01.7070000"; "Value", "17";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:02.8070000"; "Value", "67.8147664057888";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:03.4790000"; "Value", "165.814766405789";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:04.4040000"; "Value", "335.814766405789";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:05.0340000"; "Value", "514.814766405789";]
    ;                 ]               )
    ;               Xml.element "DoubleAnimationUsingKeyFrames" [ "Storyboard.TargetName", "Viewbox2"; "Storyboard.TargetProperty", "(Canvas.Top)";] (                Xml.elementList [                  Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:00"; "Value", "84.8616666666667";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:00.7110000"; "Value", "102.994319727891";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:01.7070000"; "Value", "135.861666666667";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:02.8070000"; "Value", "65.1293322940626";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:03.4140000"; "Value", "64.1293322940626";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:04.3410000"; "Value", "121.129332294063";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:04.9730000"; "Value", "121.129332294063";]
    ;                 ]               )
    ;               Xml.element "DoubleAnimationUsingKeyFrames" [ "Storyboard.TargetName", "Viewbox2"; "Storyboard.TargetProperty", "(UIElement.RenderTransform).(TransformGroup.Children)[4].(RotateTransform.Angle)";] (                Xml.elementList [                  Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:01.7070000"; "Value", "-2865.63084795133";]
    ;                   Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:04.1060000"; "Value", "-2836.74365921069";]
    ;                 ]               )
    ;               Xml.element "DoubleAnimationUsingKeyFrames" [ "Storyboard.TargetName", "Viewbox2"; "Storyboard.TargetProperty", "(FrameworkElement.Width)";] (                Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:02.8070000"; "Value", "260.370467188422";]
                  )
    ;               Xml.element "DoubleAnimationUsingKeyFrames" [ "Storyboard.TargetName", "Viewbox2"; "Storyboard.TargetProperty", "(FrameworkElement.Height)";] (                Xml.emptyElement "LinearDoubleKeyFrame" [ "KeyTime", "00:00:02.8070000"; "Value", "201.464668745208";]
                  )
    ;             ]           )
            )
          )
    ;       Xml.element "Canvas.Triggers" [] (        Xml.element "EventTrigger" [ "RoutedEvent", "FrameworkElement.Loaded"; "SourceName", "Canvas1";] (          Xml.emptyElement "BeginStoryboard" [ "Storyboard", "{DynamicResource Storyboard_0}";]
            )
          )
    ;       Xml.element "Viewbox" [ "Canvas.Left", "-51.5408163265306"; "Canvas.Top", "102.994319727891"; "Name", "Viewbox2"; "Width", "260.370467188422"; "Height", "201.464668745208"; "RenderTransformOrigin", "0.5,0.5";] (        Xml.elementList [          Xml.element "Viewbox.RenderTransform" [] (            Xml.element "TransformGroup" [] (              Xml.element "TransformGroup.Children" [] (                Xml.elementList [                  Xml.emptyElement "MatrixTransform" [ "Matrix", "Identity";]
    ;                   Xml.emptyElement "TranslateTransform" []
    ;                   Xml.emptyElement "SkewTransform" []
    ;                   Xml.emptyElement "ScaleTransform" []
    ;                   Xml.emptyElement "RotateTransform" [ "Angle", "-2836.74365921069";]
    ;                   Xml.emptyElement "TranslateTransform" []
    ;                 ]               )
                )
              )
    ;           Xml.element "Canvas" [ "Name", "Canvas3"; "Width", "500"; "Height", "500";] (            Xml.elementList [              Xml.element "Path" [ "Canvas.Left", "184"; "Canvas.Top", "184"; "Width", "269"; "Height", "316"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.emptyElement "PathGeometry" [ "Figures", "M116,55C160.666666666667,-7.86527777777775 246.5,-10.3652777777777 221,86 221,86 118.166666666667,255.468055555556 118.166666666667,255.468055555556 106.5,283.801388888889 -26.8333333333333,296.301388888889 17,245 17,245 111,58 111,58";]
                          )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "StartPoint", "0.413338449195996,0.465659771879033"; "EndPoint", "0.607696268088777,0.482125093649486";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.elementList [                          Xml.emptyElement "GradientStop" [ "Color", "#FFFF000B"; "Offset", "0.00854700854700855";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FFFF000B"; "Offset", "0.991452991452991";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FF31FF2D"; "Offset", "0.833333333333333";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FF31FF2D"; "Offset", "0.316239316239316";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FFFCFF18"; "Offset", "0.491452991452991";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FFFCFF18"; "Offset", "0.483";]
    ;                         ]                       )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "145"; "Canvas.Top", "218"; "Width", "157"; "Height", "172"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "PathGeometry" [ "Figures", "M140,14C140,14 156,32 115,50 115,50 134,58 134,58 134,58 110,106 110,106 110,106 10,51 62,21 62,21 138,11 138,11";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M83,89C83,89 67,106 108,102 108,102 81,157 81,157 9,113.718055555556 5,79 50.6666666666667,63.7180555555556 49.8333333333333,64.5513888888889 60.6666666666667,68.7180555555556 83,88";]
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "#FF315AD1"; "Offset", "0";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "75"; "Canvas.Top", "101"; "Width", "233"; "Height", "229"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.emptyElement "PathGeometry" [ "Figures", "M98,58C98,58 193,97 207,127 207,127 152,133 153,133 153,133 133,107 73.75,104.372222222222 83,105 92,61 92,61";]
                          )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.elementList [                          Xml.emptyElement "GradientStop" [ "Color", "Blue"; "Offset", "0.307692307692308";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FF46FF28"; "Offset", "0.5";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "#FF3621FF"; "Offset", "0.521367521367521";]
    ;                         ]                       )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "41"; "Canvas.Top", "101"; "Width", "136"; "Height", "181"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "4";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "PathGeometry" [ "Figures", "M99,97C99,97 94,106 80,142 80,142 50,155 50.25,155.666666666667 53,162 38,138 38,138 38,138 72,124 72,124 72,124 92,93 102,93 102,93 106,95 106,95";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M107,102C107,102 94.8333333333333,143.801388888889 72.3333333333333,163.801388888889 73,162 63,155 63,156 63,156 96,131 101,95";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M105,91C105,91 111,95 111,98 111,98 124,73 122,72 122,72 113,67 113,67 113,67 105,88 105,88";]
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "#FF28FF3C"; "Offset", "0";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "44"; "Canvas.Top", "65"; "Width", "137"; "Height", "180"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "PathGeometry" [ "Figures", "M45,46C45,46 73,21 73,21 73,21 68,41 68,40 68,40 93,26 98,31 98,31 81,48 78,48 78,48 103,39 105,52 105,52 76,73 76,73 76,73 94,73 94,73 94,73 65,95 65,95 65,95 79,94 79,94 79,94 59,118 59,118 59,118 82,123 82,123 82,123 73,134 73,134 73,134 52,121 52,121 52,121 48,147 48,147 48,147 34,148 34,148 34,148 27,80 48,43";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M21,46C21,46 39,46 39,46 39,46 29,153 29,153 29,153 12,153 9,147 9,147 -6,86.801388888889 20.6666666666667,46.8013888888889";]
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "#FFDF300D"; "Offset", "0";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "33"; "Canvas.Top", "56"; "Width", "345"; "Height", "199"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "PathGeometry" [ "Figures", "M108,68C108,68 130,81 130,81 130,81 98,130 98,130 98,130 77,146 77,146 77,146 81,125 81,125 81,125 94,107 94,107 94,107 84,102 84,102 84,102 108,84 108,84 108,84 93,78 93,78 93,78 109,68 109,68";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M66,138C66,138 79,142 68,159 68,159 54,158 63,140";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M98,101C98,101,106,101,112,91";]
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "#FFFFDBAE"; "Offset", "0.00854700854700855";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "20"; "Canvas.Top", "101"; "Width", "112"; "Height", "120"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.emptyElement "GeometryGroup" []
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.elementList [                          Xml.emptyElement "GradientStop" [ "Color", "Blue";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "DarkBlue"; "Offset", "1";]
    ;                         ]                       )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "9"; "Canvas.Top", "18"; "Width", "322"; "Height", "321"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "4";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "PathGeometry" [ "Figures", "M150,157C150,157 201,82 178,33 178,33 155,26 155,26 155,26 152,19 165,21 156.25,12.2055555555556 164.583333333333,-3.62777777777774 179,16 179,16 183,16 182,31 182,31 196,101 153,157";]
    ;                           Xml.emptyElement "PathGeometry" [ "Figures", "M138,199C138,199 105,306 51.0833333333333,274.538888888889 52,280 24,289 20,273 20,273 20,264 33,264 33,264 29,242 52,271 52,271 95,312 135,199";]
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "#FFFFAEE1"; "Offset", "0.00427350427350427";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Path" [ "Canvas.Left", "-9"; "Canvas.Top", "121"; "Width", "152"; "Height", "135"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Path.Data" [] (                    Xml.element "GeometryGroup" [] (                      Xml.element "GeometryGroup.Children" [] (                        Xml.emptyElement "PathGeometry" [ "Figures", "M64,7C64,7 55,80 62,87 62,87 37,71 37,52 37,52 51,7 64,8";]
                          )
                        )
                      )
    ;                   Xml.element "Path.Fill" [] (                    Xml.element "LinearGradientBrush" [ "Opacity", "1"; "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.emptyElement "GradientStop" [ "Color", "Black"; "Offset", "0";]
                          )
                        )
                      )
    ;                 ]               )
    ;               Xml.element "Rectangle" [ "Canvas.Left", "135.764020448638"; "Canvas.Top", "171.396018415586"; "Width", "15.5264325970313"; "Height", "15.0992771495461"; "RenderTransformOrigin", "0.5,0.5"; "Stroke", "{x:Static Brushes.Black}"; "StrokeThickness", "2";] (                Xml.elementList [                  Xml.element "Rectangle.RenderTransform" [] (                    Xml.element "TransformGroup" [] (                      Xml.element "TransformGroup.Children" [] (                        Xml.elementList [                          Xml.emptyElement "MatrixTransform" [ "Matrix", "Identity";]
    ;                           Xml.emptyElement "TranslateTransform" []
    ;                           Xml.emptyElement "SkewTransform" [ "AngleX", "0"; "AngleY", "1.43592941724456";]
    ;                           Xml.emptyElement "ScaleTransform" []
    ;                           Xml.emptyElement "RotateTransform" [ "Angle", "42.8075647799444";]
    ;                           Xml.emptyElement "TranslateTransform" []
    ;                         ]                       )
                        )
                      )
    ;                   Xml.element "Rectangle.Fill" [] (                    Xml.element "LinearGradientBrush" [ "EndPoint", "0.707106781186548,0.707106781186547";] (                      Xml.element "LinearGradientBrush.GradientStops" [] (                        Xml.elementList [                          Xml.emptyElement "GradientStop" [ "Color", "Blue"; "Offset", "0";]
    ;                           Xml.emptyElement "GradientStop" [ "Color", "DarkBlue"; "Offset", "1";]
    ;                         ]                       )
                        )
                      )
    ;                 ]               )
    ;             ]           )
    ;         ]       )
    ;       Xml.emptyElement "Polygon" [ "Fill", "White"; "Stroke", "Black"; "StrokeThickness", "2"; "Points", "5.00000000000006,321.333333333333 5.00000000000006,277.333333333333 44.0000000000001,277.092222222222 54.0000000000001,277.092222222222 60.0000000000001,277.092222222222 70.0000000000001,271.092222222222 78.0000000000001,261.092222222222 84.0000000000001,253.092222222222 89.0000000000001,245.092222222222 94.0000000000001,239.092222222222 98.0000000000001,233.092222222222 102,227.092222222222 108,223.092222222222 114,221.092222222222 120,220.092222222222 128,222.092222222222 134,226.092222222222 140,230.092222222222 147,236.092222222222 154,243.092222222222 162,251.092222222222 172,258.092222222222 181,264.092222222222 194,269.092222222222 205,271.092222222222 213,271.092222222222 220,272.092222222222 226,273.092222222222 235,273.092222222222 246,273.092222222222 256,273.092222222222 266,273.092222222222 274,273.092222222222 280,273.092222222222 287,273.092222222222 298,274.092222222222 306,274.092222222222 318,274.092222222222 327,274.092222222222 333,273.092222222222 340,271.092222222222 349,269.092222222222 360,269.092222222222 366,269.092222222222 374,269.092222222222 380,269.092222222222 386,269.092222222222 393,269.092222222222 400,269.092222222222 409,269.092222222222 417,269.092222222222 428,269.092222222222 434,269.092222222222 446,269.092222222222 453,269.092222222222 462,269.092222222222 470,269.092222222222 476,269.092222222222 482,271.092222222222 490,275.092222222222 498,277.092222222222 504,279.092222222222 510,281.092222222222 517,285.092222222222 524,287.092222222222 531,291.092222222222 537,293.092222222222 542,299.092222222222 543,305.092222222222 549,311.092222222222 556,323.241111111111";]
    ;     ]   )
    ; ] 